home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
bbs
/
cddk9606.zip
/
HEADERS.ARJ
/
MATH.INT
< prev
next >
Wrap
Text File
|
1996-06-14
|
14KB
|
563 lines
{ ───────────────────────────────────────────────────────────────────────── }
{ MATH: Mathematics }
{ Copyright 1996 David Pinch ∙ All Rights Reserved Worldwide }
{ ───────────────────────────────────────────────────────────────────────── }
UNIT Math;
{$B-} { . . . . . . . . . . . . . . . . . . . . Shortcut boolean evaluation }
{$F+} { . . . . . . . . . . . . . . . . . . . . Force far calls for safety }
{$I-} { . . . . . . . . . . . . . . . . . . . Disable input/output checking }
{$O+} { . . . . . . . . . . . . . . . . . . Allow this unit to be overlayed }
{$Q-} { . . . . . . . . . . . . . . Do not generate overflow-checking code }
{$R-} { . . . . . . . . . . . . . . . . Do not generate range-checking code }
{$S-} { . . . . . . . . . . . . . . . . Do not generate stack-checking code }
{$X+} { . . . . . . . . . . . Extended syntax for pChars and function calls }
INTERFACE
TYPE
{ Turbo Pascal Real Types }
{ }
{ ┌────────────┬─────────────────────┬────────┬────┐ }
{ │ Real │ 2.9e-39..1.7e38 │ 11-12 │ 6 │ }
{ │ + Single │ 1.5e-45..3.4e38 │ 7-8 │ 4 │ }
{ │ + Double │ 5.0e-324..1.7e308 │ 15-16 │ 8 │ }
{ │ + Extended │ 3.4e-4932..1.1e4932 │ 19-20 │ 10 │ }
{ │ + Comp │ -9.2e18..9.2e18 │ 19-20 │ 8 │ }
{ └────────────┴─────────────────────┴────────┴────┘ }
{ + MathCo required }
{$IFOPT N+}
Float = Extended;
{$ELSE}
Float = Real;
{$ENDIF}
tComplex = OBJECT
a : Float;
b : Float;
PROCEDURE Add(CONST C:tComplex);
FUNCTION Magnitude:Float;
PROCEDURE Multiply(CONST C:tComplex);
PROCEDURE Subtract(CONST C:tComplex);
END;
pComplex = ^tComplex;
tFunction = FUNCTION (x:Float):Float;
{#Start}
{ ─[ Angle Conversions ]─────────────────────────────────────────────────── }
FUNCTION Deg_Grd (CONST D:Float) : Float;
{
PURPOSE : Converts degrees to gradians.
SEE ALSO : Deg_Rad, Grd_Deg, Grd_Rad, Rad_Deg, Rad_Grd
}
FUNCTION Deg_Rad (CONST D:Float) : Float;
{
PURPOSE : Converts degrees to radians.
SEE ALSO : Deg_Grd, Grd_Deg, Grd_Rad, Rad_Deg, Rad_Grd
}
FUNCTION Grd_Deg (CONST G:Float) : Float;
{
PURPOSE : Converts gradians to degrees.
SEE ALSO : Deg_Grd, Deg_Rad, Grd_Rad, Rad_Deg, Rad_Grd
}
FUNCTION Grd_Rad (CONST G:Float) : Float;
{
PURPOSE : Converts gradians to radians.
SEE ALSO : Deg_Grd, Deg_Rad, Grd_Deg, Rad_Deg, Rad_Grd
}
FUNCTION Rad_Deg (CONST R:Float) : Float;
{
PURPOSE : Converts radians to degrees.
SEE ALSO : Deg_Grd, Deg_Rad, Grd_Deg, Grd_Rad, Rad_Grd
}
FUNCTION Rad_Grd (CONST R:Float) : Float;
{
PURPOSE : Converts radians to gradians.
SEE ALSO : Deg_Grd, Deg_Rad, Grd_Deg, Grd_Rad, Rad_Deg
}
{ ─[ Area Functions ]────────────────────────────────────────────────────── }
FUNCTION Area_Circle(CONST Radius:Float):Float;
{
PURPOSE : Calculates the area of a circle with the specified radius.
NOTES : Area = πr²
SEE ALSO : Area_Ellipse, Area_Equilateral_Triangle, Area_Rectangle,
Area_Sector, Area_Square, Area_Trapezoid, Area_Triangle
}
FUNCTION Area_Ellipse(CONST R1,R2:Float):Float;
{
PURPOSE : Calculates the area of an ellipse with the specified focal
points.
SEE ALSO : Area_Circle, Area_Equilateral_Triangle, Area_Rectangle,
Area_Sector, Area_Square, Area_Trapezoid, Area_Triangle
}
FUNCTION Area_Equilateral_Triangle(CONST S:Float):Float;
{
PURPOSE : Calculates the area of an equilateral triangle with the
given side length.
√ 3
NOTES : Area = ─── S²
4
SEE ALSO : Area_Circle, Area_Ellipse, Area_Rectangle, Area_Sector,
Area_Square, Area_Trapezoid, Area_Triangle
}
FUNCTION Area_Rectangle(CONST X,Y:Float):Float;
{
PURPOSE : Calculates the area of a rectangle with the specified side
lengths.
SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
Area_Sector, Area_Square, Area_Trapezoid, Area_Triangle
}
FUNCTION Area_Sector(CONST Radius, Angle:Float):Float;
{
PURPOSE : Calculates the area of a sector with the specified radius
and angle.
SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
Area_Rectangle, Area_Square, Area_Trapezoid, Area_Triangle
}
FUNCTION Area_Square(CONST Side:Float):Float;
{
PURPOSE : Calculates the area of a square with the specified side length.
NOTES : Area = S²
SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
Area_Rectangle, Area_Sector, Area_Trapezoid, Area_Triangle
}
FUNCTION Area_Trapezoid(CONST A,B,H:Float):Float;
{
PURPOSE : Calculates the area of a trapezoid with the specified
top, base and height.
SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
Area_Rectangle, Area_Sector, Area_Square, Area_Triangle
}
FUNCTION Area_Triangle(CONST Base,Height:Float):Float;
{
PURPOSE : Calculates the area of a triangle with the specified base
and height lengths.
NOTES : Area = ½BH
SEE ALSO : Area_Circle, Area_Ellipse, Area_Equilateral_Triangle,
Area_Rectangle, Area_Sector, Area_Square, Area_Triangle
}
{ ─[ Calculus ]──────────────────────────────────────────────────────────── }
FUNCTION Simpson(CONST y:tFUNCTION; CONST a,b,n:LongInt):Float;
{
PURPOSE : Calculates the area under the curve of the given function,
using Simpson's approximation procedure.
PARAMS : y = A Turbo Pascal function: FUNCTION(x:Float):Float
a = Lower limit
b = Upper limit
n = Number of iterations
}
{ ─[ Circumference Functions ]───────────────────────────────────────────── }
FUNCTION Circum_Circle(CONST R:Float):Float;
{
PURPOSE : Calculates the circumference of a circle with the given radius.
SEE ALSO : Circum_Ellipse
}
FUNCTION Circum_Ellipse(CONST R1,R2:Float):Float;
{
PURPOSE : Calculates the circumference of an ellipse with the given
major and minor radii.
SEE ALSO : Circum_Circle
}
{ ─[ Hyperbolic functions ]──────────────────────────────────────────────── }
FUNCTION COSH(CONST R:Float):Float;
{
PURPOSE : Calculates the hyperbolic cosine of the argument.
SEE ALSO : COTH, SECH, SINH, TANH
}
FUNCTION COTH(CONST R:Float):Float;
{
PURPOSE : Calculates the hyperbolic cotangent of the argument.
SEE ALSO : COSH, SECH, SINH, TANH
}
FUNCTION SECH(CONST R:Float):Float;
{
PURPOSE : Calculates the hyperbolic secant of the argument.
SEE ALSO : COSH, COTH, SINH, TANH
}
FUNCTION SINH(CONST R:Float):Float;
{
PURPOSE : Calculates the hyperbolic sine of the argument.
SEE ALSO : COSH, COTH, SECH, TANH
}
FUNCTION TANH(CONST R:Float):Float;
{
PURPOSE : Calculates the hyperbolic tangent of the argument.
SEE ALSO : COSH, COTH, SECH, SINH
}
{ ─[ Minimum/Maximum Functions ]─────────────────────────────────────────── }
FUNCTION MaxS(A,B:ShortInt):ShortInt;
{
PURPOSE : Returns the larger of the two ShortInts.
SEE ALSO : MinS, MaxB, MinB, MaxI, MinI, MaxW, MinW
}
FUNCTION MinS(A,B:ShortInt):ShortInt;
{
PURPOSE : Returns the lesser of the two ShortInts.
SEE ALSO : MaxS, MaxB, MinB, MaxI, MinI, MaxW, MinW
}
FUNCTION MaxB(A,B:Byte):Byte;
{
PURPOSE : Returns the larger of the two bytes.
SEE ALSO : MaxS, MinS, MinB, MaxI, MinI, MaxW, MinW